package cn.edu.gench.learn.day2;

import java.text.MessageFormat;

/**
 * @auther zhuzhongbiao
 * @date 2017/3/22 0022
 */
public class BubbleSort {

    public int[] sort(int[] wait){
        for (int i=0;i<wait.length;i++){
            for (int j=1 + i;j<wait.length;j++){
                System.out.println(MessageFormat.format("位置{0}和位置{1}比较",i,j));
                if( wait[i] < wait[j]){
                    int temp = wait[i];
                    wait[i] = wait[j];
                    wait[j] = temp;
                }
            }
        }
        return wait;
    }

    public static void main(String[] args) {
        int[] wait =  new int[]{10,3,4,100,6,7,8};
        BubbleSort bubbleSort = new BubbleSort();
        int[] finalResult = bubbleSort.sort(wait);
        for (int i=0;i<finalResult.length;i++){
            System.out.println(finalResult[i]);
        }
    }

}
